<template>
  <div class="app-container">
    <el-form label-width="120px">
      <el-form-item label="类型">
        <el-select v-model="coupon.type" placeholder="请选择类型">
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>

         
      <el-form-item label="满减底线" >
        <el-input v-model="coupon.condition" placeholder="请输入满减底线"  style="width:400px"/>
      </el-form-item>
      <el-form-item label="面值">
        <el-input v-model="coupon.value" placeholder="请输入面值"  style="width:400px"/>
      </el-form-item>
      <el-form-item label="创建时间"  style="width:200px">
        <div class="block">
          <el-date-picker
            v-model="coupon.createTime"
            type="datetime"
            placeholder="选择日期时间">
          </el-date-picker>
        </div>
      </el-form-item>
      <el-form-item label="过期时间"  style="width:200px">
        <div class="block">
          <el-date-picker
            v-model="coupon.expirationTime"
            type="datetime"
            placeholder="选择日期时间">
          </el-date-picker>
        </div>
      </el-form-item>
  
      <el-form-item>
        <el-button
          :disabled="saveBtnDisabled"
          type="primary"
          @click="addFund"
          >保存</el-button
        >
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import CouponAPI from "@/api/coupon";

export default {
  data() {
      //定义变量和初始值
    return {
      coupon: {},
      saveBtnDisabled: false, // 保存按钮是否禁用,
      imagecropperShow: false, //头像上传组件是否显示
      imagecropperKey: 0,
      BASE_API: process.env.BASE_API, //获取dev.env.js里面的地址
        position: '',
         options: [{
          value: '基金',
          label: '基金'
        }, {
          value: '黄金',
          label: '黄金'
        }, {
          value: '定期',
          label: '定期'
        }, {
          value: '活期',
          label: '活期'
        }],
    };
  },
  created() {
  },
  watch: {
  
  },
  methods: {
    //添优惠券的方法
    addFund() {
      console.log(this.coupon)
      CouponAPI.addOne(this.coupon).then((response) => {
        //添加成功
        //提示信息
        this.$message({
          type: "success",
          message: "添加成功!",
        });
        //回到教师管理页面 路由跳转
        this.$router.push({ path: "/list/coupon" });
      });
    },
  },
};
</script>
<style>
  .el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }
</style>
